//
//  PywReviseTradePwdController.m
//  PywSdk
//
//  Created by smallwave on 16/6/14.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "PywReviseTradePwdController.h"
#import "PywMasonry.h"
#import "PywTradePWDController.h"
#import "PywUserCenterCell.h"

@interface PywReviseTradePwdController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *titleArray;
@property (nonatomic, strong) NSArray *accessibilityId;

@end

@implementation PywReviseTradePwdController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.rightBarButtonItem = nil;
//    self.automaticallyAdjustsScrollViewInsets = NO;
    self.title = @"交易密码";
    [self setUpSubviewsAndLayoutSubviews];
}
- (void)setUpSubviewsAndLayoutSubviews
{
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(PywMASConstraintMaker *make) {
        make.top.left.bottom.right.offset(0);
    }];
    
    // 隐藏多余的分割线
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor clearColor];
    [self.tableView setTableFooterView:view];
}


#pragma mark - UITableViewDataSource and UITableViewDetegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 0;
    } else {
        return 2;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *identifiter = @"cell";
    PywUserCenterCell *cell = [tableView dequeueReusableCellWithIdentifier:identifiter];
    if (!cell) {
        cell = [[PywUserCenterCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifiter];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleGray;
    if (indexPath.section == 0) {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.leftTitle = self.titleArray[indexPath.row];
    [cell setAccessibilityIdentifier:self.accessibilityId[indexPath.row]];
    cell.selectBtnHidden = YES;

    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSString *requestUrl = @"";
    switch (indexPath.row) {
        case 0:
            requestUrl = self.wap_modify_paypwd_url;
            break;
        case 1:
            requestUrl = self.wap_forget_paypwd_url;
            break;
    }
    PywTradePWDController *tradeVC = [[PywTradePWDController alloc] init];
    tradeVC.wap_set_paypwd_url = requestUrl;
    [self.navigationController pushViewController:tradeVC animated:YES];
}

#pragma mark - setter & getter
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] init];
        _tableView.backgroundColor = RGB(232, 232, 232, 1);
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.showsHorizontalScrollIndicator = NO;
        _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
        _tableView.delegate = self;
        _tableView.dataSource = self;
    }
    return _tableView;
}

- (NSArray *)titleArray
{
    if (!_titleArray) {
        _titleArray = @[@"修改交易密码",@"找回交易密码"];
    }
    return _titleArray;
}
- (NSArray *)accessibilityId
{
    if (!_accessibilityId) {
        _accessibilityId = @[@"modify_paypwsd",@"getback_paypwsd"];
    }
    return _accessibilityId;
}

@end
